class Clock{
    constructor(selector){
        this.ele = document.querySelector(selector);
        this.t = 0
    }


    update_time(){
        const now = new Date();
        const hour = now.getHours().toString().padStart(2,'0');
        const minutes = now.getMinutes().toString().padStart(2,'0');
        const seconds = now.getSeconds().toString().padStart(2,'0');
        this.ele.innerText = `${hour}:${minutes}:${seconds}`
    }

    start(){
        this.update_time(); // 先更新一次 
        this.t = setInterval(()=>{
            this.update_time();
        },1000)
    }
    stop(x){
        clearInterval(this.t,x)
    }
}